package com.enation.app.javashop.core.client.fallback.distribution;

import com.enation.app.javashop.core.client.feignimpl.distribution.DistributionClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.distribution.dos.DistributionDO;
import org.springframework.stereotype.Component;

/**
 * 分销商相关熔断 factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:07
 **/
@Component
public class DistributionClientFallbackFactory extends BaseFallbackFactory<DistributionClientFeignImpl> {
    @Override
    protected DistributionClientFeignImpl fallback() {
        return new DistributionClientFallback();
    }

    /**
     * 分销商相关熔断
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 上午8:54
     * @since v7.0
     */
    @Component
    public static class DistributionClientFallback implements DistributionClientFeignImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public DistributionDO add(DistributionDO distributor) {
            logger.error("添加分销商错误,会员为" + distributor.getMemberName());
            return null;
        }

        @Override
        public DistributionDO edit(DistributionDO distributor) {
            logger.error("修改分销商错误,会员为" + distributor.getMemberName());
            return null;
        }

        @Override
        public DistributionDO getDistributorByMemberId(Long memberId) {
            logger.error("获取分销商错误,会员id为" + memberId);
            return null;
        }

        @Override
        public boolean setParentDistributorId(Long memberId, Long parentId) {
            logger.error("根据会员id设置其上级分销商,会员id为" + memberId);
            return false;
        }
    }
}
